package com.gitee.fsmxm.ocd.handler;

import com.gitee.fsmxm.ocd.exception.BaseException;
import com.gitee.fsmxm.ocd.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author fsmxm
 */
@Slf4j
@ControllerAdvice
public class OcdExceptionHandler {

    @ExceptionHandler(value = BaseException.class)
    @ResponseBody
    public Result handle(BaseException e) {
        return new Result("5555", e.getMessage(), "");
    }

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result handle(Exception e) {
        log.error("error@@@", e);
        return new Result("5555", "未知错误", "");
    }

}


